<template>
  <div class="regiter">
    <div class="title">
      <p>

        <img src="../img/backtwo.png" alt="" @click="back">

        <span class="text">手机号注册</span>

      </p>

    </div>
    <div class="plogom">
      <div class="user">
        <input type="text" placeholder="输入手机号" v-model="tel">
        <img src="../img/shouji.png" alt="">
        <span class="num">+86</span>
      </div>
      <div class="password">
        <input type="text" placeholder="设置登录密码,不少于6位" v-model="password">
        <img src="../img/mima.png" alt="">
      </div>
      <div class="loginbtn" @click="nextseup">
        下一步
      </div>

    </div>
    <otherlogin></otherlogin>
  </div>
</template>

<script>
  import otherlogin from '../components/login/otherlogin'
  export default {
    name: "regiter",
    components:{otherlogin},
    data(){
      return{
       tel:'',
       password:''
      }
    },
    methods:{
      back(){
        this.$router.push({path:'/login'})
      },
      nextseup(){
        if(this.tel.length!==11){
          this.$toast('请输入正确的手机号');
          return
        }
        if(this.password.length<6){
          this.$toast('登录密码不能少于6位');
          return
        }
        this.$http.get(`/api/cellphone/existence/check?phone=${this.tel}`)
          .then((res)=>{
            if(res.data.hasPassword){
              this.$toast('该手机号已注册')
            }else {
              this.$http.get(`/api/captcha/sent?phone=${this.tel}`)
                .then((res)=>{

                  this.$router.push({path:'/next',query:{tel:this.tel,pwd:this.password}});
                })

            }
          })
      }
    }
  }
</script>

<style lang="scss">
  *{
    margin: 0px;
    padding: 0px;
  }
  .regiter{
    width: 1245px;
    .title{
      height: 190px;
      position: relative;
      background-color: #c54a3d;
      p{
        width: 100%;

        padding-top: 50px;
        box-sizing: border-box;
        img{
          position: absolute;
          bottom: 33px;
          width: 70px;
          object-fit: cover;

        }
        .text{
          position: absolute;
          display: inline-block;
          color: white;
          font-weight: bold;
          font-size: 50px;
          left: 50%;
          bottom: 40px;
          transform: translateX(-50%);

        }
      }
    }
    .plogom{
      padding: 0 50px;
      box-sizing: border-box;
      .user{
        position: relative;
        input{
          width: 100%;
          border: none;
          box-sizing: border-box;
          padding: 40px 0;
          color: #bcbdbe;
          font-size: 50px;
          text-indent:230px;
          border-bottom: 2px solid #ccc;
        }
        .num{
          font-size: 45px;
          font-weight: bold;
          top: 50%;
          left: 92px;
          transform: translateY(-50%);
          position: absolute;
          display: inline-block;
        }

        img{
          width:60px;
          top: 50%;
          left: 12px;
          transform: translateY(-50%);
          position: absolute;
          object-fit: cover;
        }
      }
      .password{
        position: relative;
        input{
          width: 100%;
          border: none;
          box-sizing: border-box;
          padding: 40px 0;
          color: #bcbdbe;
          font-size: 50px;
          text-indent:95px;
          border-bottom: 2px solid #ccc;
        }
        img{
          width:60px;
          top: 50%;
          left: 12px;
          transform: translateY(-50%);
          position: absolute;
          object-fit: cover;
        }
      }
      .loginbtn{
        margin-top: 90px;
        background-color: #d65244;
        font-weight: bold;
        font-size: 45px;
        text-align: center;
        color: #d96355;
        line-height: 120px;
        border-radius: 60px;
      }
      .resetpassword{
        width: 167px;
        margin:0 auto;
        text-align: center;
        padding: 80px 0 10px 0;
        color: #787778;
        font-weight: bold;
        border-bottom: 5px solid #787778;
        font-size: 40px;
      }
    }
  }
</style>
